package com.example.lottery.enums;

import com.example.lottery.util.BaseModel;

/**
 * 定义HTTP code
 */
public enum HttpCodeEnum implements BaseModel {
    SUCCESS(200, "服务器响应成功！"),
    NOTFOUND(404, "请求的网页不存在"),
    BADREQUEST(400, "输入格式有误"),
    ERROR(500, "服务器内部错误"),
    ERRORVALID(700, "请求参数必填项为空！");

    private String name;
    private Integer index;

    HttpCodeEnum(Integer index, String name) {
        this.name = name;
        this.index = index;
    }

    public static String getName(String index) {
        for (HttpCodeEnum c : HttpCodeEnum.values()) {
            if (index.equals(c.getIndex())) {
                return c.name;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public Integer getIndex() {
        return index;
    }

}
